/*
 *  jMoviepilot - an interface to the database of www.moviepilot.de
 *  Copyright (C) 2011 Tobias Roettger <toroettg@gmail.com>
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *  
 *  The project site can be found at http://code.google.com/p/jmoviepilot/
 */

package de.roettger_it.jmoviepilot;

import de.roettger_it.jmoviepilot.net.MoviepilotConnection;
import de.roettger_it.jmoviepilot.util.Movie;
import de.roettger_it.jmoviepilot.util.MovieSearchResult;
import de.roettger_it.jmoviepilot.util.Neighbourhood;

/**
 * This Class is the main interface to jMoviepilot.
 * 
 * @author Tobias Roettger
 * 
 */
public class Moviepilot
{
	private String apiKey;

	/**
	 * Creates an new Moviepilot instance.
	 * 
	 * <p><b>Note:</b> Currently an api key is required to use the moviepilot database.
	 * 		 To obtain your own key, send a request to &lt;api&#064;moviepilot.de&gt;.</p>
	 * 
	 * @param apiKey the api key obtained from moviepilot
	 */
	public Moviepilot(String apiKey)
	{
		this.apiKey = apiKey;
	}
	
	/**
	 * Gets information about a single movie from the moviepilot database.
	 * 
	 * @param identifier the moviepilot identifier of the movie to get the information for (mostly the movie name) 
	 * 
	 * @return the requested Movie or null if none could be found
	 */
	public Movie getMovie(String identifier)
	{
		return MoviepilotConnection.requestMovie(identifier, apiKey);
	}
	
	/**
	 * Gets information about a single movie from the moviepilot database by an alternative identifier (e.g. IMDB ID).
	 * 
	 * @param serviceName the service name to which the identifiere belongs to
	 * @param identifier the alternative identifier of the movie to get the information for
	 * 
	 * @return the requested Movie or null if none could be found
	 */
	public Movie getMovie(String serviceName, String identifier)
	{
		return MoviepilotConnection.requestMovie(serviceName, identifier, apiKey);
	}
	
	/**
	 * Gets the neighbourhood of a single movie from the moviepilot database.
	 * 
	 * @param identifier the moviepilot identifier of the movie to get the neighbourhood for (mostly the movie name) 
	 * 
	 * @return the requested Neighbourhood or null if none could be found
	 */
	public Neighbourhood getMovieNeighbourhood(String identifier)
	{
		return MoviepilotConnection.requestMovieNeighbourhood(identifier, apiKey);
	}
	
	/**
	 * Gets the neighbourhood of a single movie from the moviepilot database by an alternative identifier (e.g. IMDB ID).
	 * 
	 * @param serviceName the service name to which the identifiere belongs to
	 * @param identifier the alternative identifier of the movie to get the neighbourhood for
	 * 
	 * @return the requested Movie or null if none could be found
	 */
	public Neighbourhood getMovieNeighbourhood(String serviceName, String identifier)
	{
		return MoviepilotConnection.requestMovieNeighbourhood(serviceName, identifier, apiKey);
	}
	
	/**
	 * Searches a movie in the moviepilot database.
	 * 
	 * @param searchTerm the term that will be searched for (mostly the movie name) 
	 * 
	 * @return the result of the search
	 */
	public MovieSearchResult searchMovie(String searchTerm)
	{
		return MoviepilotConnection.requestMovieSearch(searchTerm, apiKey);
	}
}
